package com.omega.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.omega.dao.BrandDao;
import com.omega.entity.Brand;
import com.omega.service.BrandService;

@Service
public class BrandServiceImpl implements BrandService {

	@Autowired
	BrandDao brandDao;
	
	@Override
	@Transactional
	public void addBrand(Brand brand) {
		brandDao.addBrand(brand);
	}

	@Override
	@Transactional
	public List<Brand> loadAllBrands() {
		return brandDao.loadAllBrands();
	}

	@Override
	@Transactional
	public Brand loadById(Integer brandId) {
		return brandDao.loadById(brandId);
	}

	@Override
	@Transactional
	public void updateBrand(Brand brand) {
		System.out.println("BrandID: " + brand.getbrandId());
		Brand brandEntity = brandDao.loadById(brand.getbrandId());
		System.out.println("BrandEntity: " + brandEntity);
		brandEntity.setBrandName(brand.getBrandName());
		brandDao.updateBrand(brandEntity);
	}

}
